package com.leetcode.greedy;

import java.util.Arrays;

/**
 * @author Dennis Li
 * @date 2020/7/20 11:21
 */
public class AssignCookie_455 {

    public int findContentChildren(int[] g, int[] s) {
        if (g.length == 0 || s.length == 0) return 0;
        Arrays.sort(g);
        Arrays.sort(s);
        int i = 0, j = 0;
        while (i < g.length && j < s.length) {
            // 注意每个熊孩子只能有一块饼干
            if (s[j] >= g[i]) i++;
            j++;
        }
        return i;
    }

}
